// 图片懒加载

const VLazyLoad = {
  name: 'lazy-load',
  mounted: (el, binding) => {
    const observe = new IntersectionObserver(
      ([{ isIntersecting }]) => {
        if (isIntersecting) {
          observe.unobserve(el)
          // el.src = binding.value
          binding.value.previewImgData()
        }
      },
      {
        threshold: 0,
      }
    )
    observe.observe(el)
  },
}

export default VLazyLoad
